/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cassandrawindow;

import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel;
import me.prettyprint.cassandra.serializers.StringSerializer;
import me.prettyprint.hector.api.Cluster;
import me.prettyprint.hector.api.Keyspace;
import me.prettyprint.hector.api.factory.HFactory;
import me.prettyprint.hector.api.mutation.Mutator;

import concurrentwrite.callback.run.DataQueue;

public class InitCassandra {
    private final String adsData = "AdsData";
    private Cluster cluster;
    private final String columnFamilyName = "KeyClick";
    Keyspace keyspaceOperator;
    String name = "count_click";
    
    public InitCassandra() {
        cluster = HFactory.getOrCreateCluster("Adlog cluster", "192.168.23.86:9160");
                
        ConfigurableConsistencyLevel configurableConsistencyLevel = new ConfigurableConsistencyLevel();
        keyspaceOperator = HFactory.createKeyspace(adsData, cluster, configurableConsistencyLevel);        
    }

    public void insertDataCassandra(String key, String value){
        try {
            if(!value.isEmpty()){
                Mutator<String> mutator = HFactory.createMutator(keyspaceOperator, StringSerializer.get());
                mutator.insert(key, columnFamilyName, HFactory.createStringColumn(name, value));
            }
        } catch (Exception ex){
            Debug.println(ex.getMessage());
        }
    }

    public void getDataCassandra(){
                
    }

}
